package org.basic.classloader;

public class Hello {
    static final ThreadContextClassloader contextClassLoader = new ThreadContextClassloader();

    public static void main(String[] args) {
        try {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
            Thread t = new Thread(new Runnable() {
                public void run() {
                    try {
                        
//                        UserService us = (UserService) Class.forName("org.basic.classloader.impl.UserServiceImpl").newInstance();
                        UserService us = (UserService) Thread.currentThread().getContextClassLoader().loadClass("org.basic.classloader.impl.UserServiceImpl").newInstance();
                        System.out.println(us.getUser("test01"));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            t.setContextClassLoader(contextClassLoader);
            t.start();

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}
